Page({
  onShareAppMessage() {
    return {
      title: 'form',
      path: 'page/component/pages/form/form'
    }
  },

  data: {
    pickerHidden: true,
    chosen: '',
    date: '2018-10-01'
  },   
  pickerConfirm(e) {
    this.setData({
      pickerHidden: true
    })
    this.setData({
      chosen: e.detail.value
    })
  },

  pickerCancel() {
    this.setData({
      pickerHidden: true
    })
  },

  pickerShow() {
    this.setData({
      pickerHidden: false
    })
  },

  formSubmit(e) {
    console.log('form发生了submit事件，携带数据为：', e.detail.value)
    wx.request({
      url: 'http://localhost:2238/api/Authentication/PostAddRecruitmentLibrary',
      data:{recruitmentLibrary:JSON.stringify(e.detail.value)},
      method:'POST',
      header: {'content-type':'application/x-www-form-urlencoded' }, 
      success: function (res) {
        console.log(res)
        if(res.data.Code==200)
        {
          wx.showToast({
            title: '添加成功',
            icon: 'success',
            duration: 2000//持续的时间
          }),
          setTimeout(function(){
            //添加成功跳转到首页
            wx.switchTab({
              url: '/pages/ShowRecruitmentLibrary/ShowRecruitmentLibrary'
            })
        },2000)
        }
      }
    })
  },

  formReset(e) {
    console.log('form发生了reset事件，携带数据为：', e.detail.value)
    this.setData({
      chosen: ''
    })
  }
})